

import 'package:flutter_web_2021/entity/a_factory/EntityFactory.dart';

class BaseEntity<T> {
  int code;
  String message;
  T data;

  BaseEntity({this.code, this.message, this.data});

  factory BaseEntity.fromJson(json) {


    if(json["code"]==null&&json["msg"]==null){
      return BaseEntity(
        code: 999,
        message: "无参数",
        // data值需要经过工厂转换为我们传进来的类型
        data: EntityFactory.generateOBJ<T>(json),
      );
    }else {
      return BaseEntity(
        code: json["code"],
        message: json["msg"],
        // data值需要经过工厂转换为我们传进来的类型
        data: EntityFactory.generateOBJ<T>(json["data"]),
      );
    }
  }
}